package com.shujia.io_.three;

import org.junit.Test;

import java.io.*;

public class Exer1 {



    @Test
    public void test3() {
        try (InputStream is = new FileInputStream("file\\《仙逆》.txt");
             OutputStream os = new FileOutputStream("file\\mp4\\仙逆.txt")) {

            // 一次读写一个字节数组
            byte[] bys = new byte[1024];
            int len;
            while ((len = is.read(bys)) != -1) {
                os.write(bys, 0, len);
            }

            os.close();
            is.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    @Test
    public void test2() {
        try (InputStream is = new FileInputStream("file\\鹿鼎记I_hd.mp4");
             OutputStream os = new FileOutputStream("file\\mp4\\ldj.mp4")) {

            // 一次读写一个字节数组
            byte[] bys = new byte[1024];
            int len;
            while ((len = is.read(bys)) != -1) {
                os.write(bys, 0, len);
            }

            os.close();
            is.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test1() {
        try (InputStream is = new FileInputStream("file\\鹿鼎记I_hd.mp4");
             OutputStream os = new FileOutputStream("file\\mp4\\ldj.mp4")) {

            int data;
            while ((data = is.read()) != -1) {
                os.write(data);
                os.flush();
            }

            os.close();
            is.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
